/*
package com.pro01.backend.tracker;
import java.io.File;
import java.io.FilenameFilter;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import com.turn.ttorrent.tracker.Tracker;
import com.turn.ttorrent.tracker.TrackedTorrent;

public class TrackerServer {
    public static void main(String[] args) {
        try {
            // 创建 tracker（使用 InetSocketAddress）
            InetAddress ip = InetAddress.getLocalHost();
            Tracker tracker = new Tracker(new InetSocketAddress(ip, 6969));

            // 指定种子文件夹
            File torrentDir = new File(System.getProperty("user.dir"), "uploads/torrents"); // 你实际的路径
            File[] files = torrentDir.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.endsWith(".torrent");
                }
            });

            if (files != null) {
                for (File f : files) {
                    tracker.announce(TrackedTorrent.load(f));
                    System.out.println("Announced: " + f.getName());
                }
            }

            // 启动 tracker
            tracker.start();

            // 保持运行
            System.out.println("Tracker started at http://" + ip.getHostAddress() + ":6969/announce");
            Thread.currentThread().join(); // 阻塞防止退出

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

 */


